﻿/*-------------------------------------
//
//Copyright (C) 2007 开发二组 版权所有。
//
//文件名：MyOrder.ascx.cs
//
//
//文件功能描述：我的订单....
//
//
//创建标识：2007.11.19 李正平
//创建描述：
//
//
//修改标识：2007.11.28 李正平
//修改：
//
//------------------------------------*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Common_Controls_myOrder : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            //
            //绑定输出
            //
            BindData();
        }

    }
  
    /// <summary>
    ///把顾客的订单列表绑定输出
    /// </summary>
    public void BindData()
    {

        if (Session["CustomerID"]!=null)
        {
            //
            //获取顾客登录ID
            //
            string customerID = (string)Session["CustomerID"];

            //
            //获取我的订单列表
            //
            localhost.CustomerService WSCustomer = new localhost.CustomerService();
                
            //
            //执行回调
            //
            WSCustomer.GetOrdersCompleted += new localhost.GetOrdersCompletedEventHandler(WSCustomer_GetOrdersCompleted);
            WSCustomer.GetOrdersAsync(customerID);
        }
    }


    /// <summary>
    /// 异步返回调用结果
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void WSCustomer_GetOrdersCompleted(object sender, localhost.GetOrdersCompletedEventArgs e)
    {
        if (!e.Cancelled || e.Error == null)
        {
            //
            //绑定输出
            //
            gvResult.DataSource = e.Result;
            gvResult.DataBind();
        }
        else
        {
            //
            //抛出异常
            //
            throw e.Error;
        }
    }


    /// <summary>
    /// 分页
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //获得当前页号
        this.gvResult.PageIndex = e.NewPageIndex;

        //重新绑定
        BindData();

    }


    /// <summary>
    /// 绑定数据
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvResult_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //
        //获得当前下标
        //
        int iIndex = Convert.ToInt32(e.CommandArgument);

        //
        //把所给你参数先放在Label中
        //
        lblPayMoney.Text = ((Label)gvResult.Rows[iIndex].Cells[4].FindControl("lblPay")).Text;
        lblAch.Text = ((Label)gvResult.Rows[iIndex].Cells[4].FindControl("lblAchive")).Text;
        lblOrderID.Text = this.gvResult.Rows[iIndex].Cells[0].Text;
        lblCon.Text = ((Label)gvResult.Rows[iIndex].Cells[4].FindControl("lblConsign")).Text;

        //
        //转到详细订单里面
        //

       Server.Transfer("MyDetailOrder.aspx");
    }
    protected void gvResult_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}
